<?php $i = 0; ?>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <div class="header clearfix">
        <nav>
            <ul class="nav nav-pills pull-right">
                <li role="presentation" class="active"><a href="<?php echo Yii::app()->baseUrl; ?>/admin/aboutUs">列表</a></li>
                <li role="presentation"><a href="<?php echo Yii::app()->baseUrl; ?>/admin/aboutUsChange">新增</a></li>
            </ul>
        </nav>
        <h3 class="text-muted">列表</h3>
    </div>

    <div class="table-responsive">
        <table class="table table-striped">
            <thead>
            <tr>
                <th>#</th>
                <th>类型(中)</th>
                <th>类型(英)</th>
                <th>标题(中)</th>
                <th>标题(英)</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <?php if(is_array($data)){
                foreach($data as $k => $v){
                    $i++
                    ?>

                    <tr>
                        <td><?php echo $i ?></td>
                        <td><?php echo $v['type_name_cn'] ?></td>
                        <td><?php echo $v['type_name_en'] ?></td>
                        <td><?php echo $v['title_name_cn'] ?></td>
                        <td><?php echo $v['title_name_en'] ?></td>
                        <td>
                            <a href="<?php echo Yii::app()->baseUrl; ?>/admin/aboutUsChange?id=<?php echo $v['id'] ?>">修改</a>
                            <a href="javascript:void(0)" onclick="del_show('<?php echo $v['id'] ?>')" >删除</a>
                        </td>
                    </tr>
                <?php
                }
            }?>
            <?php if($i == 0){ ?>
                <tr>
                    <td colspan="6">暂无数据</td>
                </tr>
            <?php } ?>
            </tbody>
        </table>
    </div>
    <?php echo $page_list ?>
</div>


<!-- Modal -->
<div class="modal fade" id="msgBox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body">
                确定删除吗?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="del()">确认</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var sumbit_type= 1,i=0;
    var del_id=0;
    function del_show(id){
        del_id=id;
        $('#msgBox').modal('show')
    }
    function del(){
        if(sumbit_type==0){alert('正在执行..');return false;}
        $.post("<?php echo Yii::app()->baseUrl; ?>/admin/aboutUsDel",{ id:del_id},function(data){
            if(data.length>0 && data=='ok'){
                Refresh();
            }else{
                i++;
                $('#msgBox .modal-body').html('删除失败'+i+'次,再次删除?')
                $('#msgBox').modal('show')
            }
        });
    }
    //刷新
    function Refresh() {
        location.reload();
    }
</script>
